package com.sunwayworld.basemodule.business.ordertask.resource.impl;

import com.sunwayworld.basemodule.business.ordertask.bean.LimsOrderTaskBean;
import com.sunwayworld.basemodule.business.ordertask.resource.LimsOrderTaskResource;
import com.sunwayworld.basemodule.business.ordertask.service.LimsOrderTaskService;
import com.sunwayworld.basemodule.business.ordertask.validators.LimsRunSubmitValidator;
import com.sunwayworld.framework.data.page.Page;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.validator.data.annotation.ValidateDataWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@LogModule("任务")
@RestController
@GikamBean
public class LimsOrderTaskResourceImpl implements LimsOrderTaskResource {

    @Autowired
    private LimsOrderTaskService limsOrderTaskService;

    @Override
    public LimsOrderTaskService getService() {
        return limsOrderTaskService;
    }

    @Log(value = "新增任务", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Override
    public Page<LimsOrderTaskBean> selectTest(RestJsonWrapperBean wrapperBean) {
        return getService().selectTest(wrapperBean);
    }

    @Override
    public void createRun(RestJsonWrapperBean wrapperBean) {
        getService().createRun(wrapperBean);
    }

    @Override
    public void addRunTasks(RestJsonWrapperBean wrapperBean) {
        getService().addRunTasks(wrapperBean);
    }

    @Override
    public void removeRunTasks(RestJsonWrapperBean wrapperBean) {
        getService().removeRunTasks(wrapperBean);
    }

    @Override
    public void deleteRun(RestJsonWrapperBean wrapperBean) {
        getService().deleteRun(wrapperBean);
    }

    @Log("任务分配")
    @Override
    @ValidateDataWith(LimsRunSubmitValidator.class)
    public void batchSaveAssignment(RestJsonWrapperBean wrapperBean) {
        getService().batchSaveAssignment(wrapperBean);
    }

    @Log("任务分配-提交")
    @Override
    @ValidateDataWith(LimsRunSubmitValidator.class)
    public void submit(RestJsonWrapperBean wrapperBean) {
        getService().submit(wrapperBean);
    }

    @Log("结果录入-退回调度")
    @Override
    public void backScheduling(RestJsonWrapperBean wrapperBean) {
        getService().backScheduling(wrapperBean);
    }

    @Override
    @Log(value = "结果录入查询-带结果分析项", type = LogType.CONTROLLER)
    public Page<LimsOrderTaskBean> selectOrderTaskWithResult(RestJsonWrapperBean wrapperBean) {
        return getService().selectOrderTaskWithResult(wrapperBean);
    }

    @Override
    public List<LimsOrderTaskBean> selectTestSelections(RestJsonWrapperBean wrapperBean, String status) {
        return getService().selectTestSelections(wrapperBean, status);
    }

    @Override
    public List<LimsOrderTaskBean> testSelectableList(RestJsonWrapperBean wrapper) {
        return getService().testSelectableList(wrapper);
    }

    @Override
    public Page<LimsOrderTaskBean> selectOrderTaskWithSupplement(RestJsonWrapperBean wrapper) {
        return getService().selectOrderTaskWithSupplement(wrapper);
    }

    @Override
    public void createRunWithTest(RestJsonWrapperBean wrapperBean) {
        getService().createRunWithTest(wrapperBean);
    }

    @Override
    public List<LimsOrderTaskBean> selectAbnormalTestSelections() {
        return getService().selectAbnormalTestSelections();
    }

    @Override
    public void abnormal(RestJsonWrapperBean wrapperBean) {
        getService().abnormal(wrapperBean);
    }
}
